package c.c.a;

import android.content.Context;
import c.b.a.a.a;
import com.bytedance.embed_dr.DrLogWriter;
import java.lang.reflect.Method;

public final class c0 implements d1 {
    public static Object a;
    public static Class<?> b;
    public static Method c;

    static {
        try {
            Class cls = Class.forName("com.android.id.impl.IdProviderImpl");
            b = cls;
            a = cls.newInstance();
            c = b.getMethod("getOAID", new Class[]{Context.class});
        } catch (Exception e) {
            String str = c1.j;
            StringBuilder g = a.g("Api#static reflect exception! ");
            g.append(e.getMessage());
            String stringBuilder = g.toString();
            DrLogWriter drLogWriter = u0.b;
            if (drLogWriter != null && u0.a <= 6) {
                drLogWriter.logE(str, stringBuilder, null);
            }
        }
    }

    public boolean a(Context context) {
        return (b == null || a == null || c == null) ? false : true;
    }

    public d1.a b(Context context) {
        try {
            String str;
            d1.a aVar = new d1.a();
            Method method = c;
            Object obj = a;
            if (!(obj == null || method == null)) {
                try {
                    Object invoke = method.invoke(obj, new Object[]{context});
                    if (invoke != null) {
                        str = (String) invoke;
                        aVar.a = str;
                        return aVar;
                    }
                } catch (Exception unused) {
                }
            }
            str = null;
            aVar.a = str;
            return aVar;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
